package cn.com.cennavi.test;

import java.util.HashMap;
import java.util.TreeMap;

import cn.com.cennavi.bean.HighPrecisionCombineDirTraffic;

/**
 * 用于验证分车道的对比数据对象
 * 
 * @author Thinkpad
 *
 */
public class StandardDifFromDiDiLaneData {
	public String nodeId;
	/**
	 * 时间间隔：分钟
	 */
	public int timeBuf;
	/**
	 * 同行标志：0表示直行，1表示弯行
	 */
	public int dirFlag;
	/**
	 * key:距离分歧点前的所有位置，value:速度值
	 */
	public TreeMap<Integer, Integer> disSpeedMap = new TreeMap<Integer, Integer>();
	/**
	 * 时间
	 */
	public String time;

	public StandardDifFromDiDiLaneData(String time, String nodeId, int timeBuf, int flag, String bef_straight_linkLength_speed_Arr) {
		// TODO Auto-generated constructor stub
		this.time=time;
		this.nodeId = nodeId;
		this.timeBuf = timeBuf;
		this.dirFlag = flag;
		this.disSpeedMap = getDisSpeedMap(bef_straight_linkLength_speed_Arr);
	}

	private TreeMap<Integer, Integer> getDisSpeedMap(String bef_straight_linkLength_speed_Arr) {
		// TODO Auto-generated method stub
		TreeMap<Integer, Integer> getDisSpeedMap = new TreeMap<Integer, Integer>();
		// System.out.println("-------------------");
		// System.out.println(bef_straight_linkLength_speed_Arr);
		String[] dis_SpeedArr = bef_straight_linkLength_speed_Arr.split("\\|");
		// String[] dis_SpeedArr =
		// "43_52|54_48|12_43|13_46|15_54|27_48|36_46|".split("\\|");
		int oDis = 0;
		for (int i = dis_SpeedArr.length - 1; i >= 0; i--) {
			String[] str = dis_SpeedArr[i].split("\\_");
			int nowDis = oDis + Integer.parseInt(str[0]);
			int nowSpeed = Integer.parseInt(str[1]);
			for (int j = oDis; j < nowDis; j++) {
				getDisSpeedMap.put(j, nowSpeed);
			}
			oDis = nowDis;
		}
		// System.out.println(getDisSpeedMap.keySet());
		// for (String dis_Speed : dis_SpeedArr) {
		// String[] str = dis_Speed.split("\\_");
		// int nowDis = Integer.parseInt(str[0]);
		// int nowSpeed = Integer.parseInt(str[1]);
		// for (int i = oDis; i < nowDis; i++) {
		// getDisSpeedMap.put(i, nowSpeed);
		// }
		// }
		return getDisSpeedMap;
	}

}
